#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#include<algorithm>
#define debug(a) cout<<#a<<"="<<a<<endl;
using namespace std;
const int maxn=1e4+100;
typedef long long LL;
inline LL read(){LL x=0,f=1;char ch=getchar();	while (!isdigit(ch)){if (ch=='-') f=-1;ch=getchar();}while (isdigit(ch)){x=x*10+ch-48;ch=getchar();}
return x*f;}
struct Edge{
    LL to,val;
    Edge(LL _to,LL _val){
        to=_to;val=_val;
    }
};
vector<Edge>g[maxn];
LL dp[maxn],ans=0;
void dfs(LL u,LL fa){
     for(LL i=0;i<g[u].size();i++){
         LL v=g[u][i].to;LL cost=g[u][i].val;
         if(v==fa) continue;
         dfs(v,u);
         ans=max(ans,dp[u]+dp[v]+cost);
         dp[u]=max(dp[u],dp[v]+cost);
     }
}
int main(void){
   cin.tie(0);std::ios::sync_with_stdio(false);
   LL u,v,val;
   while(scanf("%lld%lld%lld",&u,&v,&val)!=EOF){
        g[u].push_back(Edge(v,val));
        g[v].push_back(Edge(u,val));
   }
   dfs(1,0);
   cout<<ans<<"\n";
   return 0;
}
